/**
 * 
 */
package com.suyx.job.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.suyx.job.Vo.Goods;
import com.suyx.job.config.BaiduOCR;
import com.suyx.job.config.RedisUtils;
import com.suyx.job.entity.Cy;
import com.suyx.job.entity.DeviceInfo;
import com.suyx.job.entity.JobLog;
import com.suyx.job.entity.Result;
import com.suyx.job.entity.TaskInfo;
import com.suyx.job.entity.TuInfo;
import com.suyx.job.entity.TuInfoLog;
import com.suyx.job.service.ICyService;
import com.suyx.job.service.IDeviceService;
import com.suyx.job.service.IJobLogService;
import com.suyx.job.service.IRoleInfoService;
import com.suyx.job.service.ITaskInfoService;
import com.suyx.job.service.ITuInfoLogService;
import com.suyx.job.service.ITuInfoService;
import com.suyx.job.service.mh.MhxyService;
import com.suyx.job.utils.DeviceCodeMapUtil;
import com.suyx.job.utils.ImageUtils;
import com.suyx.job.utils.ScreenCapture;
import com.suyx.job.utils.SpeechUtil;

import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;


/**
 * @author Administrator
 *
 */
@Slf4j
@RestController
@RequestMapping("/mhxy")
public class MhxyController {

	
	private static final List<String> bgzb1 = Arrays.asList("730 224", "809 212", "906 233", "1000 224", "1084 224",
											          "730 321", "811 324", "909 315", "1000 320", "1080 324",
											          "724 408", "812 408", "909 408", "1000 408", "1080 408",
											          "718 492", "812 492", "909 492", "1000 492", "1080 492");

    private static final List<String> bgzb = Arrays.asList("909 315", "1000 320", "1080 324",
											         "724 408", "812 408", "909 408", "1000 408", "1080 408",
											         "718 492", "812 492", "909 492", "1000 492", "1080 492");

	
    private static final List<String> ck_bgzb = Arrays.asList("270 250", "360 250", "450 250", "540 250", "630 250",
	          "270 340", "360 340", "450 340", "540 340", "630 340",
	          "270 430", "360 430", "450 430", "540 430", "630 430",
	          "270 520", "360 520", "450 520", "540 520", "630 520");


    private static String SC_PIC_PATH = "H:\\android\\MH\\";//梦幻宝图截图放置路径
    @Autowired
    private MhxyService mhxyService;
    
    @Autowired
    private IDeviceService deviceService;
    
    @Autowired
    private  IJobLogService jobLogService;
    
    @Autowired
    private BaiduOCR baiduOCR;
    
    @Autowired
	private ITuInfoService tuInfoService;
    
    @Autowired
	private ITuInfoLogService tuInfoLogService;
    
    @Autowired
	private IRoleInfoService roleService;
    
    @Autowired
	private ITaskInfoService taskService;
    
    @Autowired
	private RedisUtils redisService;
    
    @Autowired
    private ICyService cyService;
    /*@RequestMapping("/getTaskWp/{jqNo}/{wpType}")
    public Result getTaskWp(@PathVariable("wpType") Integer wpType,
    		                @PathVariable("jqNo") Integer jqNo) throws Exception{
    	log.info("获取任务信息：wpType="+wpType+",jqNo="+jqNo);
    	TaskInfo taskInfo  = taskService.findByWpTypeAndJqNo(wpType, jqNo);
    	if(taskInfo != null){
    		return new Result(true,"返回成功",JSONArray.toJSON(taskInfo).toString());
    	}
    	return new Result(false,"获取不到任务信息失败");
    }*/
    
    public static final String APPKEY = "0086f8e05d373431";// 你的appkey
    public static final String URL = "https://api.jisuapi.com/fontconvert/convert";
    //public static final String content = "今天天气挺好的";// utf-8
    public static final String type = "2s";// 2t 2s 2h可选
 
    public  String get_convent(String content_convent) throws Exception {
        String result = null;
        String url = URL + "?appkey=" + APPKEY + "&content=" + URLEncoder.encode(content_convent,"utf-8") + "&type=" + type;
 
        try {
            result = HttpUtil.get(url);
            JSONObject json = JSONObject.parseObject(result);
            if (json.getInteger("status") != 0) {
                System.out.println(json.getString("msg"));
            } else {
                JSONObject resultarr = json.getJSONObject("result");
                String type = resultarr.getString("type");
                String content = resultarr.getString("content");
                String rcontent = resultarr.getString("rcontent");
                System.out.println(type + " " + content + " " + rcontent);
                return rcontent;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
		return content_convent;
    }
    
    @RequestMapping("/getCyName")
    public Result getCyName(String content) throws Exception{
    	//content.replace(",", "，");
    	String query_str = "";
    	String  bijiao_str = "";
    	//boolean istop = content.contains("例句");
		String[] arrays = content.split("例句");
		if(arrays.length < 2 ){
			arrays = content.split("例");
		}
		query_str = arrays[0];
		bijiao_str = arrays[1];
    	List<Cy> cyInfos = cyService.findByContent(query_str.split("。")[0].split(",")[0].substring(4));

    	if (cyInfos == null || cyInfos.size() == 0){
    		cyInfos = cyService.findByContent(get_convent(query_str.split("。")[0].split(",")[0].substring(4)));
    	}
    	if(cyInfos != null && cyInfos.size() > 0){

    		for( Cy cy:cyInfos){
    			if(bijiao_str.indexOf(cy.getName()) != -1){
    				log.info("根据释义识别成语：content="+content+",cy = " + cy.getName());
            		return new Result(true,"返回成功",JSONArray.toJSON(cy).toString());
    			}
    			String tu = bijiao_str.replace("士", "土");
    			
    			if(tu.indexOf(cy.getName()) != -1){
    				log.info("根据释义识别成语：content="+content+",cy = " + cy.getName());
            		return new Result(true,"返回成功",JSONArray.toJSON(cy).toString());
    			}
    		}
    	}
    	return new Result(false,"获取不到成语信息");
    }
    
    @RequestMapping("/getTaskWp")
    public Result getTaskWp(Integer wpType,
    		                Integer jqNo) throws Exception{
    	log.info("获取任务信息：wpType="+wpType+",jqNo="+jqNo);
    	//TaskInfo taskInfo  = taskService.findByWpTypeAndJqNo(wpType, jqNo);
    	TaskInfo taskInfo  = taskService.findByJqNoAndStatus(jqNo, "0");
    	if(taskInfo != null){
    		return new Result(true,"返回成功",JSONArray.toJSON(taskInfo).toString());
    	}
    	return new Result(false,"获取不到任务信息失败");
    }
    
    @RequestMapping("/getRedisData")
    public String getRedisData(String goodsName) throws Exception{
    	Integer data = (Integer) redisService.get(goodsName);
    	if (data != null) {
    		long timeExpire = redisService.getExpire(goodsName);
    		log.info("获取跑商商品价格："+goodsName+"-> " + data + "&" + timeExpire);
        	return data + "&" + timeExpire;
    	}
    	return "";
    }
    
    
    
    
    @RequestMapping("/saveRedisData")
    public Result saveRedisData(String goodsName,String goodsPrice,String time) throws Exception{
    	//String data = (String) redisService.get(goodsName);
    	redisService.set(goodsName, Integer.valueOf(goodsPrice),Long.valueOf(time));
    	log.info("保存跑商商品价格："+goodsName+"-> " + goodsPrice +"-> "+ time);
    	return new Result(true,"返回成功");
    }
    
    @RequestMapping("/delRedisData")
    public Result delRedisData(String goodsName) throws Exception{
    	redisService.del(goodsName);
    	log.info("删除跑商商品价格："+goodsName);
    	return new Result(true,"返回成功");
    }
    
    @RequestMapping("/chooseBestGoodsManBuy")
    public Result chooseBestGoodsManBuy(String server,String area,String totalMoney) throws Exception{
    	Integer totalYp = Integer.valueOf(totalMoney);
    	List<Goods> goodsList = getPsGoodsList(true,"",server,area,totalYp);
    	// 过滤比基准值高的数据
        List<Goods> filterList = goodsList.stream()
        		.filter(t -> t.getGoodsPrice1() > 0)
        		.filter(t -> t.getSubValue() > 0)
        		.collect(Collectors.toList());
        
        
        //排序
        List<Goods> sortList = filterList.stream()
        		.sorted((a, b) -> (int)b.getDivValue() - (int)a.getDivValue())
        		.collect(Collectors.toList());
        
        if(sortList!= null && sortList.size() > 0){
        	List<Goods> choocegoods_wuqi  = sortList.stream().filter(t ->"商品武器".equals(t.getGoodsName())).collect(Collectors.toList());
        	if (choocegoods_wuqi.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_wuqi.get(0)).toString());
        	}
        	
        	List<Goods> choocegoods_fozhu  = sortList.stream().filter(t ->"商品佛珠".equals(t.getGoodsName())).collect(Collectors.toList());
        	
        	if (choocegoods_wuqi.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_fozhu.get(0)).toString());
        	}
        	
        	
        	
        	List<Goods> choocegoods_lurong  = sortList.stream().filter(t ->"商品鹿茸".equals(t.getGoodsName())).collect(Collectors.toList());
        	if (choocegoods_wuqi.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_lurong.get(0)).toString());
        	}
        	
        	List<Goods> choocegoods_fu  = sortList.stream().filter(t ->"商品符".equals(t.getGoodsName())).collect(Collectors.toList());
        	
        	if (choocegoods_wuqi.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_fu.get(0)).toString());
        	}
        	
        	
        	
        	Goods goods = sortList.get(0);
        	return new Result(true,"返回成功",JSONArray.toJSON(goods).toString());
        }
        Goods goods = goodsList.get(0);
    	return new Result(true,"返回成功",JSONArray.toJSON(goods).toString());
    }
    
    @RequestMapping("/chooseBestGoodsMan1Buy")
    public Result chooseBestGoodsMan1Buy(String server,String area,String totalMoney) throws Exception{
    	Integer totalYp = Integer.valueOf(totalMoney);
    	List<Goods> goodsList = getPsGoodsList(false,"1",server,area,totalYp);
    	// 过滤比基准值高的数据
        List<Goods> filterList = goodsList.stream()
        		.filter(t -> t.getGoodsPrice1() > 0)
        		.filter(t -> t.getSubValue() > 0)
        		.collect(Collectors.toList());
        //排序
        List<Goods> sortList = filterList.stream()
        		.sorted((a, b) -> (int)b.getDivValue() - (int)a.getDivValue())
        		.collect(Collectors.toList());
        if(sortList!= null && sortList.size() > 0){
        	List<Goods> choocegoods_wuqi  = sortList.stream().filter(t ->"商品武器".equals(t.getGoodsName())).collect(Collectors.toList());
        	if (choocegoods_wuqi.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_wuqi.get(0)).toString());
        	}
        	
        	List<Goods> choocegoods_fozhu  = sortList.stream().filter(t ->"商品佛珠".equals(t.getGoodsName())).collect(Collectors.toList());
        	
        	if (choocegoods_fozhu.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_fozhu.get(0)).toString());
        	}
        	
        	
        	
        	List<Goods> choocegoods_lurong  = sortList.stream().filter(t ->"商品鹿茸".equals(t.getGoodsName())).collect(Collectors.toList());
        	if (choocegoods_lurong.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_lurong.get(0)).toString());
        	}
        	
        	List<Goods> choocegoods_fu  = sortList.stream().filter(t ->"商品符".equals(t.getGoodsName())).collect(Collectors.toList());
        	
        	if (choocegoods_fu.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_fu.get(0)).toString());
        	}
        	
        	Goods goods = sortList.get(0);
        	return new Result(true,"返回成功",JSONArray.toJSON(goods).toString());
        }
        return new Result(false,"返回成功");
    }
    
    @RequestMapping("/chooseBestGoodsMan2Buy")
    public Result chooseBestGoodsMan2Buy(String server,String area,String totalMoney) throws Exception{
    	Integer totalYp = Integer.valueOf(totalMoney);
    	List<Goods> goodsList = getPsGoodsList(false,"2",server,area,totalYp);
    	// 过滤比基准值高的数据
        List<Goods> filterList = goodsList.stream()
        		.filter(t -> t.getGoodsPrice1() > 0)
        		.filter(t -> t.getSubValue() > 0)
        		.collect(Collectors.toList());
        //排序
        List<Goods> sortList = filterList.stream()
        		.sorted((a, b) -> (int)b.getDivValue() - (int)a.getDivValue())
        		.collect(Collectors.toList());
        if(sortList!= null && sortList.size() > 0){
        	List<Goods> choocegoods_wuqi  = sortList.stream().filter(t ->"商品武器".equals(t.getGoodsName())).collect(Collectors.toList());
        	if (choocegoods_wuqi.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_wuqi.get(0)).toString());
        	}
        	
        	List<Goods> choocegoods_fozhu  = sortList.stream().filter(t ->"商品佛珠".equals(t.getGoodsName())).collect(Collectors.toList());
        	
        	if (choocegoods_fozhu.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_fozhu.get(0)).toString());
        	}
        	
        	
        	
        	List<Goods> choocegoods_lurong  = sortList.stream().filter(t ->"商品鹿茸".equals(t.getGoodsName())).collect(Collectors.toList());
        	if (choocegoods_lurong.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_lurong.get(0)).toString());
        	}
        	
        	List<Goods> choocegoods_fu  = sortList.stream().filter(t ->"商品符".equals(t.getGoodsName())).collect(Collectors.toList());
        	
        	if (choocegoods_fu.size() > 0) {
        		return new Result(true,"返回成功",
        				JSONArray.toJSON(choocegoods_fu.get(0)).toString());
        	}
        	
        	Goods goods = sortList.get(0);
        	return new Result(true,"返回成功",JSONArray.toJSON(goods).toString());
        }
        return new Result(false,"返回成功");
    }
    
    
    @RequestMapping("/chooseBestGoodsManSeller")
    public String chooseBestGoodsManSeller(String server,String area) throws Exception{
        return getPsGoodsManBestSeller(server,area);
    }
    
    
    @RequestMapping("/updateTaskWp")
    public Result updateTaskWp(Integer roleId,String taskText) throws Exception{
     	TaskInfo updateTask = taskService.findByRoleIdAndTaskText(String.valueOf(roleId), taskText);
    	if(updateTask != null){
    		updateTask.setStatus("1");
    		taskService.saveAndFlush(updateTask);
        	return new Result(true,"更新成功");
    	}
    	return new Result(false,"更新失败");
    }
    
    
   // @RequestMapping(value="/readTuDate/{deviceCode}")
    @PostMapping(value="readTuDate")
    public Result readTuDate(String deviceCode) throws Exception{
    	String path = SC_PIC_PATH + deviceCode +"\\";
    	File file = new File(path);
        if (!file.exists()){
            file.mkdir();
        }
        tuInfoService.deleteByDeviceAndStatus(deviceCode, "0");
        ScreenCapture.mouseClick(deviceCode, "1308 675");//  # 打开包裹
    	for(String bg : bgzb){
    		TuInfo btInfo = null;
    		ScreenCapture.mouseClick(deviceCode, bg);
			Thread.sleep(2 * 500L);
			ScreenCapture.snapshot(deviceCode,path, "screen.png");
			//剪切到宝图坐标
			ImageUtils.cutPNG(new FileInputStream(path +"screen.png"),
                       new FileOutputStream(path + "btAddr.png"), 375,335,232,36);
			//读取宝图坐标地址信息
			String bgZuobiao = baiduOCR.generalBasic(path + "btAddr.png");
			if(StringUtils.isEmpty(bgZuobiao)){
				log.info("读取宝图坐标地址信息为空："+ bg );
				continue;
			}
			String[] zb = bgZuobiao.replace(" ", "").split("\\(");
			if(zb.length == 2){
				btInfo = new TuInfo();
				btInfo.setDevice(deviceCode);
				btInfo.setScene(zb[0]);// 场景
				//btInfo.setLocationX(Integer.valueOf(bg.split(" ")[0]));//包裹位置x
				//btInfo.setLocationY(Integer.valueOf(bg.split(" ")[1]));//包裹位置y
				String[] z = zb[1].replace(".", ",").replace(")", "").split(",");
				if(z.length == 2){
					btInfo.setZuobiaoX(Integer.valueOf(z[0]));
					btInfo.setZuobiaoY(Integer.valueOf(z[1]));
					btInfo.setRemark(bgZuobiao);
					tuInfoService.save(btInfo);
				}
				
				if(z.length != 2){
					bgZuobiao = baiduOCR.accurateBasic(path + "btAddr.png");
					zb = bgZuobiao.replace(" ", "").split("\\(");
					if(zb.length == 2){
						btInfo = new TuInfo();
						btInfo.setDevice(deviceCode);
						btInfo.setScene(zb[0]);// 场景
						//btInfo.setLocationX(Integer.valueOf(bg.split(" ")[0]));//包裹位置x
						//btInfo.setLocationY(Integer.valueOf(bg.split(" ")[1]));//包裹位置y
						z = zb[1].replace(".", ",").replace(")", "").split(",");
						if(z.length == 2){
							btInfo.setZuobiaoX(Integer.valueOf(z[0]));
							btInfo.setZuobiaoY(Integer.valueOf(z[1]));
							btInfo.setRemark(bgZuobiao);
							tuInfoService.save(btInfo);
						}
					}
				}
				
			}else{
				log.info("读取宝图坐标地址信息有误："+bgZuobiao);
				continue;
			}
			
			if (btInfo != null){
				TuInfoLog tuInfoLog = new TuInfoLog();
				tuInfoLog.setDevice(btInfo.getDevice());
				tuInfoLog.setRemark(btInfo.getRemark());
				tuInfoLog.setCreateTime(new Date());
				tuInfoLogService.save(tuInfoLog);
			}
    	}
    	SpeechUtil.textToSpeech(DeviceCodeMapUtil.deviceCode_map.get(deviceCode)+"号机器读取藏宝图数据完毕");
    	return new Result(true,"宝图数据读取完成!");
    }
    
    /**
     * dt
     * @throws Exception 
     */
    @PostMapping(value="/dt")
    public Result dt(String deviceCode) throws Exception
    {
    	Sort sort = new Sort(Sort.Direction.DESC,"scene");
    	List<TuInfo> baoTus= tuInfoService.findByDevice(deviceCode, sort);

    	JobLog jobLog = new JobLog();
    	JobLog jobLog1 = new JobLog();
    	jobLog1.setStartTime(new Date());

    	ScreenCapture.mouseClick(deviceCode, "1308 675");
    	ScreenCapture.mouseClick(deviceCode, "1084 224");//摄妖香
		ScreenCapture.mouseClick(deviceCode, "522 422");// 使用
		ScreenCapture.mouseClick(deviceCode, "1156 52");// 关闭包裹
        DeviceInfo deviceInfo = deviceService.findByDevice(deviceCode);
		for(TuInfo baoTu : baoTus){
			log.info(DeviceCodeMapUtil.deviceCode_map.get(deviceCode)+"号机器开始挖图场景："+baoTu.getDevice()+ baoTu.getRemark());
			jobLog.setStartTime(new Date());
    		if((baoTu.getScene().indexOf("麒麟山") != -1 
    				|| baoTu.getScene().indexOf("麒") != -1) 
    				&& deviceInfo != null && "1".equals(deviceInfo.getRemark1()) ){
    			continue;
    		}
			mhxyService.playBaoTu(baoTu,deviceInfo);
			if(deviceInfo != null ){
				log.info(DeviceCodeMapUtil.deviceCode_map.get(deviceCode)+"号机器挖图结束一个场景："+baoTu.getDevice()+ baoTu.getRemark());
				jobLog.setJobName(deviceInfo.getDeviceName());
				jobLog.setCronExpression(baoTu.getScene()+baoTu.getZuobiaoX()+","+baoTu.getZuobiaoY());
				jobLog.setJobGroup("0");
				jobLog.end(new Result(true,deviceInfo.getDeviceName()+baoTu.getScene()+"dt完成!"));
				try {
		            jobLogService.save(jobLog);
		        } catch (Exception e) {
		            log.error("报错日志失败！！！" );
		        }
			}
		}
		try {
			jobLog1.setJobName(deviceInfo.getDeviceName());
			jobLog1.setJobGroup("1");
			jobLog1.end(new Result(true,deviceInfo.getDeviceName()+"dt全部完成!"));
			SpeechUtil.textToSpeech(DeviceCodeMapUtil.deviceCode_map.get(deviceCode)+"号机器打图全部完成");
            jobLogService.save(jobLog1);
        } catch (Exception e) {
            log.error("报错日志失败！！！");
        }
		return new Result(true,"dt完成!");
    }
    
    
    private List<Goods> getPsGoodsList(boolean isflag,String chooseGoodsMan,String server,String area,Integer totalYp){
    	
    	List<Goods> list = new ArrayList<>();
    	if ("CA".equals(area)){
    		Integer data_fozhu0 = (Integer) redisService.get("商品佛珠0");
    		Integer data_wuqi0 = (Integer) redisService.get("商品武器0");
    		Integer data_shanzi0 = (Integer) redisService.get("商品扇子0");
    		Integer data_mianbu0 = (Integer) redisService.get("商品棉布0");
    		
    		Integer data_fozhu1 = (Integer) redisService.get(server+"商品佛珠1");
    		Integer data_wuqi1 = (Integer) redisService.get(server+"商品武器1");
    		Integer data_shanzi1 = (Integer) redisService.get(server+"商品扇子1");
    		Integer data_mianbu1 = (Integer) redisService.get(server+"商品棉布1");
    		
    		Integer data_fozhu2 = (Integer) redisService.get(server+"商品佛珠2");
    		Integer data_wuqi2 = (Integer) redisService.get(server+"商品武器2");
    		Integer data_shanzi2 = (Integer) redisService.get(server+"商品扇子2");
    		Integer data_mianbu2 = (Integer) redisService.get(server+"商品棉布2");
    		//选择商品
    		Goods goods = new Goods();
    		
    		if(isflag){
    			if (data_fozhu1 == null || data_fozhu2 == null){
        			return list;
        		}
    			
    			if (data_fozhu1 < data_fozhu2){
        			chooseGoodsMan = "1";
        		}else{
        			chooseGoodsMan = "2";
        		}
    		}
    		
    		
			goods.setGoodsName("商品佛珠");
			goods.setGoodsPrice0(data_fozhu0);
			goods.setGoodsPrice1(data_fozhu1 == null ? 0 :data_fozhu1);
			goods.setNum("1");
        	goods.setArea("CA");
            if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_fozhu2  == null ? 0 :data_fozhu2);
            	goods.setNum("2");
			}
            if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			
			goods = new Goods();
			goods.setGoodsName("商品武器");
			goods.setGoodsPrice0(data_wuqi0);
			goods.setGoodsPrice1(data_wuqi1  == null ? 0 :data_wuqi1);
			goods.setNum("1");
        	goods.setArea("CA");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_wuqi2 == null ? 0: data_wuqi2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    		
			goods = new Goods();
			goods.setGoodsName("商品扇子");
			goods.setGoodsPrice0(data_shanzi0);
			goods.setGoodsPrice1(data_shanzi1 == null ? 0:data_shanzi1);
			goods.setNum("1");
        	goods.setArea("CA");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_shanzi2== null ? 0:data_shanzi2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品棉布");
			goods.setGoodsPrice0(data_mianbu0);
			goods.setGoodsPrice1(data_mianbu1 == null ? 0:data_mianbu1);
			goods.setNum("1");
        	goods.setArea("CA");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_mianbu2 == null ? 0:data_mianbu2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    	}
    	
    	
    	if ("CS".equals(area)){
    		Integer data_mucai0 = (Integer) redisService.get("商品木材0");
    		Integer data_lurong0 = (Integer) redisService.get("商品鹿茸0");
    		Integer data_mianfen0 = (Integer) redisService.get("商品面粉0");
    		Integer data_fu0 = (Integer) redisService.get("商品符0");
    		
    		Integer data_mucai1 = (Integer) redisService.get(server+"商品木材1");
    		Integer data_lurong1 = (Integer) redisService.get(server+"商品鹿茸1");
    		Integer data_mianfen1 = (Integer) redisService.get(server+"商品面粉1");
    		Integer data_fu1 = (Integer) redisService.get(server+"商品符1");
    		
    		Integer data_mucai2 = (Integer) redisService.get(server+"商品木材2");
    		Integer data_lurong2 = (Integer) redisService.get(server+"商品鹿茸2");
    		Integer data_mianfen2 = (Integer) redisService.get(server+"商品面粉2");
    		Integer data_fu2 = (Integer) redisService.get(server+"商品符2");
    		//选择商品
    		Goods goods = new Goods();
    		
    		
    		if(isflag){
    			if (data_lurong1 == null || data_lurong2 == null){
        			return list;
        		}
    			
    			if (data_lurong1 < data_lurong2){
        			chooseGoodsMan = "1";
        		}else{
        			chooseGoodsMan = "2";
        		}
    		}

    		
			goods.setGoodsName("商品木材");
			goods.setGoodsPrice0(data_mucai0);
			goods.setGoodsPrice1(data_mucai1 == null ? 0:data_mucai1);
			goods.setNum("1");
        	goods.setArea("CS");
            if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_mucai2 == null ?0 :data_mucai2);
            	goods.setNum("2");
			}
            if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品鹿茸");
			goods.setGoodsPrice0(data_lurong0);
			goods.setGoodsPrice1(data_lurong1 == null ? 0:data_lurong1);
			goods.setNum("1");
        	goods.setArea("CS");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_lurong2 == null ? 0:data_lurong2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    		
			goods = new Goods();
			goods.setGoodsName("商品面粉");
			goods.setGoodsPrice0(data_mianfen0);
			goods.setGoodsPrice1(data_mianfen1 == null ? 0 :data_mianfen1);
			goods.setNum("1");
        	goods.setArea("CS");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_mianfen2 == null ? 0 :data_mianfen2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品符");
			goods.setGoodsPrice0(data_fu0);
			goods.setGoodsPrice1(data_fu1 == null ? 0 :data_fu1);
			goods.setNum("1");
        	goods.setArea("CS");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_fu2 == null ? 0 :data_fu2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    	}
    	
    	
    	
    	if ("AL".equals(area)){
    		Integer data_maozi0 = (Integer) redisService.get("商品帽子0");
    		Integer data_yan0 = (Integer) redisService.get("商品盐0");
    		Integer data_jiu0 = (Integer) redisService.get("商品酒0");
    		Integer data_lazhu0 = (Integer) redisService.get("商品蜡烛0");
    		
    		Integer data_maozi1 = (Integer) redisService.get(server+"商品帽子1");
    		Integer data_yan1 = (Integer) redisService.get(server+"商品盐1");
    		Integer data_jiu1 = (Integer) redisService.get(server+"商品酒1");
    		Integer data_lazhu1 = (Integer) redisService.get(server+"商品蜡烛1");
    		
    		Integer data_maozi2 = (Integer) redisService.get(server+"商品帽子2");
    		Integer data_yan2 = (Integer) redisService.get(server+"商品盐2");
    		Integer data_jiu2 = (Integer) redisService.get(server+"商品酒2");
    		Integer data_lazhu2 = (Integer) redisService.get(server+"商品蜡烛2");
    		//选择商品
    		Goods goods = new Goods();
    		
    		
    		if(isflag){
    			if (data_jiu1 == null || data_jiu2 == null){
        			return list;
        		}
    			
    			if (data_jiu1 < data_jiu2){
        			chooseGoodsMan = "1";
        		}else{
        			chooseGoodsMan = "2";
        		}
    		}
    		
    		
			goods.setGoodsName("商品帽子");
			goods.setGoodsPrice0(data_maozi0);
			goods.setGoodsPrice1(data_maozi1 == null ? 0 :data_maozi1);
			goods.setNum("1");
        	goods.setArea("AL");
            if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_maozi2 == null ? 0 :data_maozi2);
            	goods.setNum("2");
			}
            if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品盐");
			goods.setGoodsPrice0(data_yan0);
			goods.setGoodsPrice1(data_yan1 == null ? 0 :data_yan1);
			goods.setNum("1");
        	goods.setArea("AL");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_yan2 == null ? 0 :data_yan2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    		
			goods = new Goods();
			goods.setGoodsName("商品酒");
			goods.setGoodsPrice0(data_jiu0);
			goods.setGoodsPrice1(data_jiu1 == null ? 0 :data_jiu1);
			goods.setNum("1");
        	goods.setArea("AL");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_jiu2 == null ? 0 :data_jiu2 );
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品蜡烛");
			goods.setGoodsPrice0(data_lazhu0);
			goods.setGoodsPrice1(data_lazhu1 == null ? 0 :data_lazhu1);
			goods.setNum("1");
        	goods.setArea("AL");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_lazhu2 == null ? 0 :data_lazhu2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    	}
    	
    	if ("BJ".equals(area)){
    		Integer data_yijia0 = (Integer) redisService.get("商品衣甲0");
    		Integer data_rensheng0 = (Integer) redisService.get("商品人参0");
    		Integer data_lingdang0 = (Integer) redisService.get("商品铃铛0");
    		Integer data_you0 = (Integer) redisService.get("商品油0");
    		
    		Integer data_yijia1 = (Integer) redisService.get(server+"商品衣甲1");
    		Integer data_rensheng1 = (Integer) redisService.get(server+"商品人参1");
    		Integer data_lingdang1 = (Integer) redisService.get(server+"商品铃铛1");
    		Integer data_you1 = (Integer) redisService.get(server+"商品油1");
    		
    		Integer data_yijia2 = (Integer) redisService.get(server+"商品衣甲2");
    		Integer data_rensheng2 = (Integer) redisService.get(server+"商品人参2");
    		Integer data_lingdang2 = (Integer) redisService.get(server+"商品铃铛2");
    		Integer data_you2 = (Integer) redisService.get(server+"商品油2");
    		//选择商品
    		Goods goods = new Goods();
    		
    		if(isflag){
    			
    			if (data_rensheng1 == null || data_rensheng2 == null){
        			return list;
        		}
    			
    			if (data_rensheng1 < data_rensheng2){
        			chooseGoodsMan = "1";
        		}else{
        			chooseGoodsMan = "2";
        		}
    		}
    		
    		
			goods.setGoodsName("商品衣甲");
			goods.setGoodsPrice0(data_yijia0);
			goods.setGoodsPrice1(data_yijia1 == null ? 0 :data_yijia1);
			goods.setNum("1");
        	goods.setArea("BJ");
            if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_yijia2  == null ? 0 :data_yijia2 );
            	goods.setNum("2");
			}
            if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品人参");
			goods.setGoodsPrice0(data_rensheng0);
			goods.setGoodsPrice1(data_rensheng1 == null ? 0 :data_rensheng1);
			goods.setNum("1");
        	goods.setArea("BJ");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_rensheng2  == null ? 0 :data_rensheng2 );
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    		
			goods = new Goods();
			goods.setGoodsName("商品铃铛");
			goods.setGoodsPrice0(data_lingdang0);
			goods.setGoodsPrice1(data_lingdang1 == null ? 0 :data_lingdang1);
			goods.setNum("1");
        	goods.setArea("BJ");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_lingdang2 == null ? 0 :data_lingdang2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品油");
			goods.setGoodsPrice0(data_you0);
			goods.setGoodsPrice1(data_you1 == null ? 0:data_you1);
			goods.setNum("1");
        	goods.setArea("BJ");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_you2 == null ? 0:data_you2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    	}
    	
    	if ("DF".equals(area)){
    		Integer data_zhiqian0 = (Integer) redisService.get("商品纸钱0");
    		Integer data_yemingzhu0 = (Integer) redisService.get("商品夜明珠0");
    		Integer data_shoushi0 = (Integer) redisService.get("商品首饰0");
    		Integer data_zhengzhu0 = (Integer) redisService.get("商品珍珠0");
    		
    		Integer data_zhiqian1 = (Integer) redisService.get(server+"商品纸钱1");
    		Integer data_yemingzhu1 = (Integer) redisService.get(server+"商品夜明珠1");
    		Integer data_shoushi1 = (Integer) redisService.get(server+"商品首饰1");
    		Integer data_zhengzhu1 = (Integer) redisService.get(server+"商品珍珠1");
    		
    		Integer data_zhiqian2 = (Integer) redisService.get(server+"商品纸钱2");
    		Integer data_yemingzhu2 = (Integer) redisService.get(server+"商品夜明珠2");
    		Integer data_shoushi2 = (Integer) redisService.get(server+"商品首饰2");
    		Integer data_zhengzhu2 = (Integer) redisService.get(server+"商品珍珠2");
    		//选择商品
    		Goods goods = new Goods();
    		
    		if(isflag){
    			if (data_yemingzhu1 == null || data_yemingzhu2 == null){
        			return list;
        		}
    			if (data_yemingzhu1 < data_yemingzhu2){
        			chooseGoodsMan = "1";
        		}else{
        			chooseGoodsMan = "2";
        		}
    		}
    		
    		
			goods.setGoodsName("商品纸钱");
			goods.setGoodsPrice0(data_zhiqian0);
			goods.setGoodsPrice1(data_zhiqian1 == null ? 0 :data_zhiqian1);
			goods.setNum("1");
        	goods.setArea("DF");
            if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_zhiqian2 == null ? 0 :data_zhiqian2);
            	goods.setNum("2");
			}
            if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品夜明珠");
			goods.setGoodsPrice0(data_yemingzhu0);
			goods.setGoodsPrice1(data_yemingzhu1 == null ? 0 :data_yemingzhu1);
			goods.setNum("1");
        	goods.setArea("DF");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_yemingzhu2 == null ? 0 :data_yemingzhu2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    		
			goods = new Goods();
			goods.setGoodsName("商品首饰");
			goods.setGoodsPrice0(data_shoushi0);
			goods.setGoodsPrice1(data_shoushi1 == null ? 0 :data_shoushi1);
			goods.setNum("1");
        	goods.setArea("DF");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_shoushi2 == null ? 0 :data_shoushi2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
			
			goods = new Goods();
			goods.setGoodsName("商品珍珠");
			goods.setGoodsPrice0(data_zhengzhu0);
			goods.setGoodsPrice1(data_zhengzhu1 == null ? 0:data_zhengzhu1 );
			goods.setNum("1");
        	goods.setArea("DF");
			if("2".equals(chooseGoodsMan)){
            	goods.setGoodsPrice1(data_zhengzhu2 == null ? 0:data_zhengzhu2);
            	goods.setNum("2");
			}
			if(goods.getGoodsPrice1() != 0){
            	goods.setSubValue(goods.getGoodsPrice0() - goods.getGoodsPrice1());
    			goods.setDivValue(totalYp / goods.getGoodsPrice1());
    			goods.setCuValue(totalYp % goods.getGoodsPrice1());
    			list.add(goods);
            }
    	}
    	
    	return list;
    }
    
    private String getPsGoodsManBestSeller(String server,String area){
    	String  chooseGoodsMan = "";
    	if ("CA".equals(area)){
    		
    		Integer data_fozhu1 = (Integer) redisService.get(server+"商品佛珠1");
    		Integer data_wuqi1 = (Integer) redisService.get(server+"商品武器1");
    		Integer data_shanzi1 = (Integer) redisService.get(server+"商品扇子1");
    		Integer data_mianbu1 = (Integer) redisService.get(server+"商品棉布1");
    		
    		Integer data_fozhu2 = (Integer) redisService.get(server+"商品佛珠2");
    		Integer data_wuqi2 = (Integer) redisService.get(server+"商品武器2");
    		Integer data_shanzi2 = (Integer) redisService.get(server+"商品扇子2");
    		Integer data_mianbu2 = (Integer) redisService.get(server+"商品棉布2");
    		//选择商品
    		
    		if(data_fozhu2 == null || data_fozhu1 == null){
    			return "3";//未知
    		}
    		if (data_fozhu2 < data_fozhu1){
    			chooseGoodsMan = "1";
    		}else{
    			chooseGoodsMan = "2";
    		}
    		return chooseGoodsMan;
    	}
    	
    	
    	if ("CS".equals(area)){
    		Integer data_mucai1 = (Integer) redisService.get(server+"商品木材1");
    		Integer data_lurong1 = (Integer) redisService.get(server+"商品鹿茸1");
    		Integer data_mianfen1 = (Integer) redisService.get(server+"商品面粉1");
    		Integer data_fu1 = (Integer) redisService.get(server+"商品符1");
    		
    		Integer data_mucai2 = (Integer) redisService.get(server+"商品木材2");
    		Integer data_lurong2 = (Integer) redisService.get(server+"商品鹿茸2");
    		Integer data_mianfen2 = (Integer) redisService.get(server+"商品面粉2");
    		Integer data_fu2 = (Integer) redisService.get(server+"商品符2");
    		//选择商品
    		if(data_lurong2 == null || data_lurong1 == null){
    			return "3";//未知
    		}
    		
    		if (data_lurong2 < data_lurong1){
    			chooseGoodsMan = "1";
    		}else{
    			chooseGoodsMan = "2";
    		}
    		return chooseGoodsMan;
    	}
    	
    	
    	
    	if ("AL".equals(area)){
    		Integer data_maozi1 = (Integer) redisService.get(server+"商品帽子1");
    		Integer data_yan1 = (Integer) redisService.get(server+"商品盐1");
    		Integer data_jiu1 = (Integer) redisService.get(server+"商品酒1");
    		Integer data_lazhu1 = (Integer) redisService.get(server+"商品蜡烛1");
    		
    		Integer data_maozi2 = (Integer) redisService.get(server+"商品帽子2");
    		Integer data_yan2 = (Integer) redisService.get(server+"商品盐2");
    		Integer data_jiu2 = (Integer) redisService.get(server+"商品酒2");
    		Integer data_lazhu2 = (Integer) redisService.get(server+"商品蜡烛2");
    		//选择商品
    		if(data_jiu2 == null || data_jiu1 == null){
    			return "3";//未知
    		}
    		
    		if (data_jiu2 < data_jiu1){
    			chooseGoodsMan = "1";
    		}else{
    			chooseGoodsMan = "2";
    		}
    		return chooseGoodsMan;
    	}
    	
    	if ("BJ".equals(area)){
    		
    		Integer data_yijia1 = (Integer) redisService.get(server+"商品衣甲1");
    		Integer data_rensheng1 = (Integer) redisService.get(server+"商品人参1");
    		Integer data_lingdang1 = (Integer) redisService.get(server+"商品铃铛1");
    		Integer data_you1 = (Integer) redisService.get(server+"商品油1");
    		
    		Integer data_yijia2 = (Integer) redisService.get(server+"商品衣甲2");
    		Integer data_rensheng2 = (Integer) redisService.get(server+"商品人参2");
    		Integer data_lingdang2 = (Integer) redisService.get(server+"商品铃铛2");
    		Integer data_you2 = (Integer) redisService.get(server+"商品油2");
    		//选择商品
    		if(data_rensheng2 == null || data_rensheng1 == null){
    			return "3";//未知
    		}
    		
    		if (data_rensheng2 < data_rensheng1){
    			chooseGoodsMan = "1";
    		}else{
    			chooseGoodsMan = "2";
    		}
    		return chooseGoodsMan;
    	}
    	
    	if ("DF".equals(area)){
    		Integer data_zhiqian1 = (Integer) redisService.get(server+"商品纸钱1");
    		Integer data_yemingzhu1 = (Integer) redisService.get(server+"商品夜明珠1");
    		Integer data_shoushi1 = (Integer) redisService.get(server+"商品首饰1");
    		Integer data_zhengzhu1 = (Integer) redisService.get(server+"商品珍珠1");
    		
    		Integer data_zhiqian2 = (Integer) redisService.get(server+"商品纸钱2");
    		Integer data_yemingzhu2 = (Integer) redisService.get(server+"商品夜明珠2");
    		Integer data_shoushi2 = (Integer) redisService.get(server+"商品首饰2");
    		Integer data_zhengzhu2 = (Integer) redisService.get(server+"商品珍珠2");
    		//选择商品
    		if (data_yemingzhu2 < data_yemingzhu1){
    			chooseGoodsMan = "1";
    		}else{
    			chooseGoodsMan = "2";
    		}
    		return chooseGoodsMan;
    	}
		return chooseGoodsMan;
    }
}
